/**
 * @param {number[]} nums
 * @return {number[]}
 */
var singleNumbers = function (nums) {
  let res = []
  nums.sort((a, b) => a - b)
  for (let i = 0; i < nums.length - 1;) {
    if (nums[i] != nums[i + 1]) {
      res.push(nums[i])
      i++
    } else {
      i += 2
    }
  }
  if (res.length == 1) res.push(nums.length - 1)
  return res
};